'''
small helper function for developping

Created on Jan 24, 2010

@author: eqijian
'''
import sys

def format_exception(type=None, value=None, tb=None, limit=None):
    """ format the current system exception stack string.
    """
    if type is None:
        type, value, tb = sys.exc_info()
    import traceback
    exc_str =  "Traceback (most recent call last):\n"
    list = traceback.format_tb(tb, limit) + \
           traceback.format_exception_only(type, value)
    exc_str = ("at:%s \n exception:",
        list[:-1],
        list[-1],
        )
    del tb
